<template>
    <div class="doc-content-wrapper">
        <div class="doc-content-container">
            <div class="doc-content">
                <h2 class="mb-5 flex items-center">修改对象嵌套对象的某一个值</h2>
                <Codemirror :code="code1" name="修改对象嵌套对象的某一个值" class="mb-10" />
            </div>
        </div>
    </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'

export default defineComponent({
    setup () {
        const code1 = ref(`let data =  {
    id: 1,
    userInfoDto: {
        count: 12,
        name: '小女孩',
        phone: 12345678
    }
}
        
const newData = {
    ...data,
    userInfoDto: {
        ...data.userInfoDto,
        name: '小男孩',
    },
};

console.log(JSON.stringify(newData))`)

        return {
            code1
        }
    }
})
</script>

<style scoped>

</style>